<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('commerce_contract', function (Blueprint $table) {
            $table->comment('合同');
            $table->unsignedBigInteger('id')->comment('合同编号');
            $table->unsignedBigInteger('merchant_id')->unsigned()->comment('商户ID');
            $table->string('contract_title', 128)->comment('合同标题');
            $table->string('party_a', 128)->comment('甲方');
            $table->string('party_b', 128)->comment('乙方');
            $table->decimal('contract_amount', 15, 2)->nullable()->comment('合同金额');
            $table->date('sign_date')->comment('签订日期');
            $table->date('effective_date')->comment('生效日期');
            $table->date('expiry_date')->comment('到期日期');
            $table->string('contract_file', 255)->nullable()->comment('合同文件路径');
            $table->json('attachment_files')->nullable()->comment('附件文件路径（JSON格式）');
            $table->unsignedTinyInteger('payment_method')->nullable()->comment('付款方式1-银行转账,2-微信支付,3-支付宝支付,4-现金,5-其他付款方式');
            $table->text('remark')->nullable()->comment('合同备注');
            $table->timestamps();
            $table->softDeletes();
            $table->index('merchant_id', 'idx_merchant_id');
            $table->index('sign_date', 'idx_sign_date');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('commerce_contract');
    }
};